# include <stdio.h> 
# include <string.h>
int  lastnumble( char a[i]);
int main(){
	int i,n,x=0;
	scanf("%d",&n);
    char a[n][19];
    for(i=0;i<n;i++){
    	scanf("%s",&a[i]);
    	printf("%s\n",a[i]);
    	if((strcmp(lastnumble(&a[i]),a[i][18]))!=0){
    		printf("%s\n",a[i]);x=1;
		}
	}
	if(x==0){ printf("All passed");
	}
   return 0;
}

 char*lastnumble( char a[i]){
	int j,s=0,count=0;
	int b[17]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
	for(j=0;j<17;j++){
		s+=a[i][j]*b[j];
		count+=b[j];
	}
	char m[12]={'1','0','X','9','8','7','6','5','4','3','2','\0'}; 
	return m[s/count%11];
}
